var express = require('express');
var router = express.Router();

const {userModel} = require('../models/model');
router.post('/register', async (req, res) => {
    const {username, password} = req.body;
    const user = await userModel.findOne({username});
    if(user){
        res.send({code: 1, msg: '用户已存在'});
    }
    const newUser = new userModel({username, password});
    await newUser.save();
    res.send({code: 0, msg: '注册成功'});
})
module.exports = router;
